package demo4;

class Money implements Cloneable {
    public double money = 12.25;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Studebt implements Cloneable{
    public String naem;
    public Money m = new Money();

    @Override
    public String toString() {
        return "Studebt{" +
                "naem='" + naem + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Studebt studebt =(Studebt)super.clone();
        studebt.m=(Money)this.m.clone();
        return studebt;

    }
}
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException{
        Studebt studebt1 = new Studebt();
        studebt1.naem="hhhhhh";
        Studebt studebt2 = (Studebt)studebt1.clone();
        System.out.println(studebt1.m.money);
        System.out.println(studebt2.m.money);
        System.out.println("=================");
        studebt1.m.money=99;
        System.out.println(studebt1.m.money);
        System.out.println(studebt2.m.money);
    }
}
